package com.wangke.ck.demos.config;

import lombok.Data;

/************
 * @anter 王珂
 * @version 1.0
 *************/
@Data
public class Result {

    private Integer code;  //状态码
    private String msg;  //成功失败
    private Long total;  //总条数
    private Object data; //数据

    public static  Result result(int code,String msg,Long total,Object data){
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setTotal(total);
        result.setData(data);
        return result;
    }

    public static Result fail(){
        return result(400,"失败",0L,null);
    }

    public static Result success(){
        return result(200,"成功",0L,null);
    }

    public static Result success(Object data){
        return result(200,"成功",0L,data);
    }

    public static Result success(Long total,Object data){
        return result(200,"成功",total,data);
    }

    public static Result success(Object data,Long total){
        return result(200,"成功",total,data);
    }
}
